<?php
/*
+ ----------------------------------------------------------------------------------------------+
|     e107 website system  : http://e107.org.ru
|     Released under the terms and conditions of the GNU General Public License (http://gnu.org).
|
|     Plugin "roll_mini"
|     Author: Alex ANP alex-anp@ya.ru
|     Home page: http://e107plugins.blogspot.com
+-----------------------------------------------------------------------------------------------+
*/

$advanced_where = "";

// The fields that will be returned by the SQL
$return_fields = "id, index_name, name, description, description_2, id_cat
";

// The fields that can be search for matches
$search_fields = array("name", 
                       "description", 
                       "description_2");

// A weighting for the importance of finding a match in each of the search fields
$weights = array("1.2", "0.8", "1.2", "1.0", "0.8");

// Message to be displayed when no matches found
$no_results = LAN_198;

// The SQL WHERE clause, if any
$where = "1 and".$advanced_where;

// The SQL ORDER BY columns as a keyed array
$order = array('name' => ASC);

// The table(s) to be searched
$table = "roll_mini_cards";

// Perform the search
$ps = $sch->parsesearch($table, $return_fields, $search_fields, $weights, 
                        'search_roll', $no_results, $where, $order);

// Assign the results to specific variables
$text .= $ps['text'];
$results = $ps['results'];

// A callback function (name is passed to the parsesearch() function above)
// It is passed a single row from the DB result set
function search_roll($row) {
   global $pref;
   global $con;

   // Populate as many of the $res array keys as is sensible for the plugin
   $res['link'] = e_PLUGIN."roll_mini/roll.php?cat=".$row["id_cat"]."&card_id=".$row["id"];
   $res['pre_title'] = "";
   $res['title'] = $row["name"];
   $res['pre_summary'] = "<div class='smalltext' style='padding: 2px 0px'>";
   $res['pre_summary'] .= "<a href='".e_PLUGIN."roll_mini/roll.php?cat=".$row["id_cat"]."'>".$pref['roll_m_name']."</a>";
   $res['pre_summary'] .= " -> <a href='".e_PLUGIN."roll_mini/roll.php?cat=".$row["id_cat"]."&index_name=".$row["index_name"]."'>".$row["index_name"]."</a>";
   $res['pre_summary'] .= " -> ".$row["name"]."";
   $res['pre_summary'] .= "</div>";
   $res['summary'] = $row["description"].$row["description_2"];
   $res['detail'] = "<a href='".e_PLUGIN."roll_mini/roll.php?cat=".$row["id_cat"]."&card_id=".$row["id"]."'>http://".$_SERVER["HTTP_HOST"].e_HTTP.$PLUGINS_DIRECTORY."roll_mini/roll.php?cat=".$row["id_cat"]."&card_id=".$row["id"]."</a>";
   return $res;
}
?> 